// Copyright (c) 2009 Luca Marrocco.
// Modified or written by Luca Marrocco for inclusion with codej.
// Licensed under the Apache License, Version 2.0 (the "License")
package codej.ast;

import java.util.*;

import codej.ast.*;

/** @author Luca Marrocco */
public abstract class TypeDeclaration extends BodyDeclaration implements Documentable<TypeDeclaration> {

	private List<TypeParameter> typeParameters;
	private String name;
	private Documentation documentation;
	private List<Type> extendsTypes;
	private List<Type> implementsTypes;
	private List<BodyDeclaration> bodyDeclarations;
	private Modifiers modifiers;

	public TypeDeclaration() {
		this.typeParameters = new LinkedList<TypeParameter>();
		this.extendsTypes = new LinkedList<Type>();
		this.implementsTypes = new LinkedList<Type>();
		this.bodyDeclarations = new LinkedList<BodyDeclaration>();
	}

	public TypeDeclaration addBodyDeclaration(BodyDeclaration bodyDeclaration) {
		addChild(bodyDeclaration);
		bodyDeclarations.add(bodyDeclaration);
		return this;
	}

	public TypeDeclaration addExtendsType(Type extendsType) {
		extendsTypes.add(extendsType);
		return this;
	}

	public TypeDeclaration addExtendsTypes(List<Type> types) {
		for (Type type : types) {
			addExtendsType(type);
		}
		return this;
	}

	public TypeDeclaration addImplementsType(Type implementsType) {
		implementsTypes.add(implementsType);
		return this;
	}

	public TypeDeclaration addImplementsTypes(List<Type> types) {
		for (Type type : types) {
			addImplementsType(type);
		}
		return this;
	}

	public TypeDeclaration addModifier(Modifier modifier) {
		addChild(modifier);
		return this;
	}

	public TypeDeclaration addModifiers(List<Modifier> modifiers) {
		for (Modifier modifier : modifiers) {
			addModifier(modifier);
		}
		return this;
	}

	public TypeDeclaration addTypeParameter(TypeParameter typeParameter) {
		typeParameters.add(typeParameter);
		return this;
	}

	public TypeDeclaration addTypeParameters(List<TypeParameter> typeParameters) {
		for (TypeParameter typeParameter : typeParameters) {
			addTypeParameter(typeParameter);
		}
		return this;
	}

	public List<BodyDeclaration> getBodyDeclarations() {
		return bodyDeclarations;
	}

	public Documentation getDocumentation() {
		return documentation;
	}

	public List<Type> getExtendsTypes() {
		return extendsTypes;
	}

	public List<Type> getImplementsTypes() {
		return implementsTypes;
	}

	public String getName() {
		return name;
	}

	public List<TypeParameter> getTypeParameters() {
		return typeParameters;
	}

	public TypeDeclaration setDocumentation(Documentation documentation) {
		this.documentation = documentation;
		return this;
	}

	public TypeDeclaration setName(String name) {
		this.name = name;
		return this;
	}
}